import { useEffect, useState } from "react"
import { fetchTaskHistory } from "../services/api"

export function useTaskLog(taskId: string | null, visible: boolean) {
  const [logs, setLogs] = useState<string[]>([])

  useEffect(() => {
    if (visible && taskId) {
      fetchTaskHistory(taskId).then(setLogs)
    }
  }, [visible, taskId])

  return { logs, setLogs }
}
